package com.example.orderflow.controller;

import java.util.List;

import com.example.orderflow.controller.base.ABaseController;
import com.example.orderflow.entity.query.OrderEquipmentQuery;
import com.example.orderflow.entity.po.OrderEquipment;
import com.example.orderflow.entity.vo.ResponseVO;
import com.example.orderflow.service.OrderEquipmentService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 *  Controller
 */
@RestController("orderEquipmentController")
@RequestMapping("/orderEquipment")
public class OrderEquipmentController extends ABaseController {

	@Resource
	private OrderEquipmentService orderEquipmentService;
	/**
	 * 根据条件分页查询
	 */
	@RequestMapping("/loadDataList")
	public ResponseVO loadDataList(OrderEquipmentQuery query){
		return getSuccessResponseVO(orderEquipmentService.findListByPage(query));
	}

	/**
	 * 新增
	 */
	@RequestMapping("/add")
	public ResponseVO add(OrderEquipment bean) {
		orderEquipmentService.add(bean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 批量新增
	 */
	@RequestMapping("/addBatch")
	public ResponseVO addBatch(@RequestBody List<OrderEquipment> listBean) {
		orderEquipmentService.addBatch(listBean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 批量新增/修改
	 */
	@RequestMapping("/addOrUpdateBatch")
	public ResponseVO addOrUpdateBatch(@RequestBody List<OrderEquipment> listBean) {
		orderEquipmentService.addBatch(listBean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 根据Id查询对象
	 */
	@RequestMapping("/getOrderEquipmentById")
	public ResponseVO getOrderEquipmentById(Integer id) {
		return getSuccessResponseVO(orderEquipmentService.getOrderEquipmentById(id));
	}

	/**
	 * 根据Id修改对象
	 */
	@RequestMapping("/updateOrderEquipmentById")
	public ResponseVO updateOrderEquipmentById(OrderEquipment bean,Integer id) {
		orderEquipmentService.updateOrderEquipmentById(bean,id);
		return getSuccessResponseVO(null);
	}

	/**
	 * 根据Id删除
	 */
	@RequestMapping("/deleteOrderEquipmentById")
	public ResponseVO deleteOrderEquipmentById(Integer id) {
		orderEquipmentService.deleteOrderEquipmentById(id);
		return getSuccessResponseVO(null);
	}
}